package org.nicocube.airain.domain.server.storable;

import java.io.Serializable;
import java.util.Date;

import javax.jdo.annotations.Column;
import javax.jdo.annotations.Embedded;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import org.nicocube.airain.domain.client.character.Gender;
import org.nicocube.airain.domain.client.gamedate.GameDate;
import org.nicocube.airain.domain.server.dao.DomainEntity;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class GameCharacterStorable implements DomainEntity,Serializable {

	private static final long serialVersionUID = 1L;

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long order;

	@Persistent
	private String name;

	@Persistent
	private Date creationDate;
	
	@Persistent
	@Embedded(members={@Persistent(name="timestamp",columns=@Column(name="birthDateTimestamp"))})
	private GameDate birthDate;

	@Persistent
	@Embedded(members={@Persistent(name="timestamp",columns=@Column(name="liveDateTimestamp"))})
	private GameDate livedate;
	
	@Persistent
	private Gender gender;

	@Persistent
	private Long playerId;

	protected GameCharacterStorable(Long order, String name, Gender gender, Long playerId, Date creationDate, GameDate current) {
		this.order = order;
		this.name = name;
		this.gender = gender;
		this.playerId = playerId;
		this.creationDate = creationDate;
		this.birthDate = new GameDate(current);
		this.livedate = current;
	}

	public Long getOrder() {
		return order;
	}

	public String getName() {
		return name;
	}

	public Date getCreationDate() {
		return creationDate;
	}

	public GameDate getGameDate() {
		return birthDate;
	}

	public GameDate getLivedate() {
		return livedate;
	}

	public void setLivedate(GameDate livedate) {
		this.livedate = livedate;
	}

	public Gender getGender() {
		return gender;
	}

	public Long getPlayerId() {
		return playerId;
	}
}

